package com.kczd.jinlan.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.kczd.jinlan.R;
import com.kczd.jinlan.activity.AssessActivity;
import com.kczd.jinlan.activity.LogisticsActivity;
import com.kczd.jinlan.adapter.normaladapter.BaseCommAdapter;
import com.kczd.jinlan.adapter.normaladapter.ViewHolder;
import com.kczd.jinlan.model.Goods;

import java.util.List;

/**
 * yang_g
 * 已完成
 * Created by Administrator on 2017/5/29.
 */

public class CompLetedAdapter extends BaseCommAdapter<Goods> {
    public CompLetedAdapter(List<Goods> datas) {
        super(datas);
    }

    @Override
    protected void setUI(ViewHolder holder, int position, final Context context) {
        Goods cd = getItem(position);
        TextView text_title_id = holder.getItemView(R.id.text_title_id);
        text_title_id.setText(cd.getTitle());

        TextView text_id_count = holder.getItemView(R.id.text_id_count);
        text_id_count.setText(cd.getWeight_dai());

        TextView text_id_price = holder.getItemView(R.id.text_id_price);
        text_id_price.setText(cd.getPrice());

        TextView text_id_time = holder.getItemView(R.id.text_id_time);
        text_id_time.setText(cd.getPay_time());

        TextView text_id_sum = holder.getItemView(R.id.text_id_sum);
        text_id_sum.setText(cd.getCount_this());

        TextView text_id_pricesum = holder.getItemView(R.id.text_id_pricesum);
        text_id_pricesum.setText(cd.getSumprice());

        TextView textView2 = holder.getItemView(R.id.textView2);
        textView2.setText(cd.getYunfei());

        Button but_cancel = holder.getItemView(R.id.but_id_cancle);
        but_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(context, "查看物流", Toast.LENGTH_SHORT).show();
                context.startActivity(new Intent(context, LogisticsActivity.class));
            }
        });

        Button but_payment = holder.getItemView(R.id.but_id_ok);
        but_payment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(context, "我要评价", Toast.LENGTH_SHORT).show();
                context.startActivity(new Intent(context, AssessActivity.class));
            }
        });
    }

    @Override
    protected int getLayoutId() {
        return R.layout.item_list_completed;
    }
}
